#include "ezqaudioplayerbuffer.h"
#include "log/EZQLOG.h"

EZQAudioPlayerBuffer::EZQAudioPlayerBuffer()
{
    setOpenMode(QIODevice::ReadWrite);
    _readOil = 0;
    _writeOil = 0;
}


qint64 EZQAudioPlayerBuffer::readData(char *data, qint64 maxlen)
{
    if(maxlen==0){
        return 0;
    }
    qint64 hasLen = _decode->pcmBufSize() ;//_writeOil - _readOil;
    qint64 readLen = maxlen > hasLen? hasLen:maxlen;
    readLen = _decode->readPcmBuf((unsigned char*)data,readLen);

//    EZDebug << "player read: maxlen:" <<readLen << maxlen;
    return readLen;
}

qint64 EZQAudioPlayerBuffer::writeData(const char */*data*/, qint64 /*len*/)
{
    return 0;
}
